home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_11
/
2n11047a
< prev
next >
Wrap
Text File
|
1991-08-05
|
1KB
|
53 lines
/* Windows Initialization Files -- sample source code Listing 3
* Kevin H. Carlson 8/07/91
*/
/* The WIN.INI file contains a section named [windows] that has a
* key called device. For the purpose of this example, that line
* is given to be:
*
* [windows]
* device=PostScript Printer,PSCRIPT,LPT1:
*
*/
.
.
.
HDC hPrinterDC;
char deviceStr[80];
int resultLength;
LPSTR driverName;
LPSTR deviceName = NULL;
LPSTR output = NULL;
// create printer DC
resultLength = GetProfileString((LPSTR)"windows", (LPSTR)"device",
"", deviceStr, sizeof(deviceStr));
/* replace commas with Nulls and set parameter pointers */
driverName = (LPSTR) deviceStr;
for(i = 0; i < resultLength; i++)
{
if(deviceStr[i] == ',')
{
deviceStr[i] = '\0';
if(!deviceName)
deviceName = &deviceStr[i+1];
else
{
output= &deviceStr[i+1];
break;
}
}
}
/* create printer DC */
hPrinterDC = CreateDC(deviceName, driverName, output, NULL);
.
.
.